package main

import (
	"fmt"
	"os"
)

func main() {
	file, err := os.OpenFile(
		"./song.txt",
		os.O_CREATE|os.O_TRUNC|os.O_WRONLY, // 模式
		0666,
	)
	if err != nil {
		fmt.Println("open file failed, err:", err)
		return
	}
	defer file.Close()
	str := "hello,松鼠"
	file.Write([]byte(str))         //写入字节切片数据
	file.WriteString("hello,jar壳虫") //直接写入字符串数据
}
